﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Assets.Scripts.GtsScripts;
using SizeboxUI;
using UnityEngine;

// Token: 0x0200037C RID: 892
public class InterfaceControl : MonoBehaviour
{
	// Token: 0x17000393 RID: 915
	// (get) Token: 0x0600171C RID: 5916 RVA: 0x0009441F File Offset: 0x0009261F
	// (set) Token: 0x0600171D RID: 5917 RVA: 0x00094427 File Offset: 0x00092627
	public EntityBase selectedEntity { get; private set; }

	// Token: 0x17000394 RID: 916
	// (get) Token: 0x0600171E RID: 5918 RVA: 0x00094430 File Offset: 0x00092630
	// (set) Token: 0x0600171F RID: 5919 RVA: 0x00094438 File Offset: 0x00092638
	public Humanoid humanoid { get; private set; }

	// Token: 0x17000395 RID: 917
	// (get) Token: 0x06001720 RID: 5920 RVA: 0x00094441 File Offset: 0x00092641
	// (set) Token: 0x06001721 RID: 5921 RVA: 0x00094449 File Offset: 0x00092649
	public Giantess giantess { get; private set; }

	// Token: 0x17000396 RID: 918
	// (get) Token: 0x06001722 RID: 5922 RVA: 0x00094452 File Offset: 0x00092652
	// (set) Token: 0x06001723 RID: 5923 RVA: 0x0009445A File Offset: 0x0009265A
	public List<Sprite[]> catalog { get; private set; }

	// Token: 0x17000397 RID: 919
	// (get) Token: 0x06001724 RID: 5924 RVA: 0x00094463 File Offset: 0x00092663
	// (set) Token: 0x06001725 RID: 5925 RVA: 0x0009446B File Offset: 0x0009266B
	public string[] animations { get; private set; }

	// Token: 0x17000398 RID: 920
	// (get) Token: 0x06001726 RID: 5926 RVA: 0x00094474 File Offset: 0x00092674
	// (set) Token: 0x06001727 RID: 5927 RVA: 0x0009447C File Offset: 0x0009267C
	public bool lockRotation { get; private set; }

	// Token: 0x17000399 RID: 921
	// (get) Token: 0x06001728 RID: 5928 RVA: 0x00094485 File Offset: 0x00092685
	// (set) Token: 0x06001729 RID: 5929 RVA: 0x0009448D File Offset: 0x0009268D
	public float lastMicroScale { get; private set; }

	// Token: 0x1700039A RID: 922
	// (get) Token: 0x0600172A RID: 5930 RVA: 0x00094496 File Offset: 0x00092696
	// (set) Token: 0x0600172B RID: 5931 RVA: 0x0009449E File Offset: 0x0009269E
	public float lastMacroScale { get; private set; }

	// Token: 0x1700039B RID: 923
	// (get) Token: 0x0600172C RID: 5932 RVA: 0x000944A7 File Offset: 0x000926A7
	// (set) Token: 0x0600172D RID: 5933 RVA: 0x000944AF File Offset: 0x000926AF
	public IOManager modelManager { get; private set; }

	// Token: 0x1400000A RID: 10
	// (add) Token: 0x0600172E RID: 5934 RVA: 0x000944B8 File Offset: 0x000926B8
	// (remove) Token: 0x0600172F RID: 5935 RVA: 0x000944F0 File Offset: 0x000926F0
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	public event InterfaceControl.Selected OnSelected;

	// Token: 0x06001730 RID: 5936 RVA: 0x00094528 File Offset: 0x00092728
	private void Awake()
	{
		InterfaceControl.Instance = this;
		this.modelManager = IOManager.Instance;
		this.lastMacroScale = InterfaceControl.macroStartingScale;
		this.lastMicroScale = InterfaceControl.microStartingScale;
		this.lockRotation = false;
		this.SetSelectedObject(null, true);
		this.catalog = new List<Sprite[]>();
		this.catalog.Add(this.modelManager.GetObjectsThumbnails());
		this.catalog.Add(this.modelManager.GetGtsThumbnails());
		this.catalog.Add(Resources.LoadAll<Sprite>("PosesThumb"));
		this.catalog.Add(this.modelManager.GetFemaleMicroThumbnails());
		this.catalog.Add(this.modelManager.GetMaleMicroThumbnails());
		this.animations = this.modelManager.GetAnimationList();
	}

	// Token: 0x06001731 RID: 5937 RVA: 0x000945F4 File Offset: 0x000927F4
	public void SetSelectedObject(EntityBase obj, bool selectSceneListEntry = true)
	{
		if (selectSceneListEntry && this.selectedEntity != null)
		{
			SceneTreeView sceneTreeView = Camera.main.GetComponent<GameController>().view.editMode.sceneTreeView;
			if (sceneTreeView.gameObject.activeSelf)
			{
				sceneTreeView.SetSelectedByObject(this.selectedEntity.gameObject, false);
			}
		}
		this.selectedEntity = obj;
		if (this.selectedEntity == null)
		{
			this.humanoid = null;
			this.giantess = null;
		}
		else
		{
			this.humanoid = this.selectedEntity.GetComponent<Humanoid>();
			this.giantess = this.selectedEntity.GetComponent<Giantess>();
			if (selectSceneListEntry)
			{
				SceneTreeView sceneTreeView2 = Camera.main.GetComponent<GameController>().view.editMode.sceneTreeView;
				if (sceneTreeView2.gameObject.activeSelf)
				{
					sceneTreeView2.SetSelectedByObject(obj.gameObject, true);
				}
			}
		}
		if (this.OnSelected != null)
		{
			this.OnSelected();
		}
	}

	// Token: 0x06001732 RID: 5938 RVA: 0x000946F4 File Offset: 0x000928F4
	public float GetYRotation()
	{
		if (this.selectedEntity)
		{
			this.lastRotationY = 0f;
		}
		return 0f;
	}

	// Token: 0x06001733 RID: 5939 RVA: 0x00094716 File Offset: 0x00092916
	public float GetXRotation()
	{
		if (this.selectedEntity)
		{
			this.lastRotationX = 0f;
		}
		return 0f;
	}

	// Token: 0x06001734 RID: 5940 RVA: 0x00094738 File Offset: 0x00092938
	public float GetZRotation()
	{
		if (this.selectedEntity)
		{
			this.lastRotationZ = 0f;
		}
		return 0f;
	}

	// Token: 0x06001735 RID: 5941 RVA: 0x0009475A File Offset: 0x0009295A
	public void RotateYAxis(float angle)
	{
		if (this.selectedEntity)
		{
			this.selectedEntity.ChangeRotation(new Vector3(0f, this.lastRotationY - angle, 0f));
			this.lastRotationY = angle;
		}
	}

	// Token: 0x06001736 RID: 5942 RVA: 0x00094795 File Offset: 0x00092995
	public void RotateXAxis(float angle)
	{
		if (this.selectedEntity)
		{
			this.selectedEntity.ChangeRotation(new Vector3(this.lastRotationX - angle, 0f, 0f));
			this.lastRotationX = angle;
		}
	}

	// Token: 0x06001737 RID: 5943 RVA: 0x000947D0 File Offset: 0x000929D0
	public void RotateZAxis(float angle)
	{
		if (this.selectedEntity)
		{
			this.selectedEntity.ChangeRotation(new Vector3(0f, 0f, this.lastRotationZ - angle));
			this.lastRotationZ = angle;
		}
	}

	// Token: 0x06001738 RID: 5944 RVA: 0x0009480C File Offset: 0x00092A0C
	public void SetScale(float scale)
	{
		if (this.selectedEntity)
		{
			scale /= 100f;
			float newScale = Mathf.Pow(10f, scale);
			this.selectedEntity.ChangeScale(newScale);
			if (this.selectedEntity.isGiantess)
			{
				this.lastMacroScale = this.selectedEntity.Scale;
			}
			else
			{
				this.lastMicroScale = this.selectedEntity.Scale;
			}
		}
	}

	// Token: 0x06001739 RID: 5945 RVA: 0x00094884 File Offset: 0x00092A84
	public float GetScale()
	{
		if (this.selectedEntity)
		{
			return Mathf.Log10(this.selectedEntity.transform.lossyScale.y) * 100f;
		}
		return 1f;
	}

	// Token: 0x0600173A RID: 5946 RVA: 0x000948CC File Offset: 0x00092ACC
	public float GetYAxisOffset()
	{
		float num = 0f;
		if (this.selectedEntity != null)
		{
			num = this.selectedEntity.offset * 300f;
			if (this.giantess)
			{
				num *= this.giantessOffsetDivisor;
			}
		}
		else
		{
			UnityEngine.Debug.Log("object null");
		}
		return num;
	}

	// Token: 0x0600173B RID: 5947 RVA: 0x0009492C File Offset: 0x00092B2C
	public void SetYAxisOffset(float offset)
	{
		if (this.selectedEntity)
		{
			offset /= 300f;
			if (this.giantess)
			{
				offset /= this.giantessOffsetDivisor;
			}
			this.selectedEntity.ChangeOffset(offset);
		}
	}

	// Token: 0x0600173C RID: 5948 RVA: 0x00094978 File Offset: 0x00092B78
	public Giantess.MorphData[] GetMorphList()
	{
		if (this.giantess == null)
		{
			return null;
		}
		return this.giantess.Morphs;
	}

	// Token: 0x0600173D RID: 5949 RVA: 0x00094998 File Offset: 0x00092B98
	public void SetMorph(int i, float weight)
	{
		if (this.giantess == null)
		{
			return;
		}
		this.giantess.SetMorphValue(i, weight);
	}

	// Token: 0x0600173E RID: 5950 RVA: 0x000949BC File Offset: 0x00092BBC
	public void SetAnimation(string animationName)
	{
		if (this.humanoid == null)
		{
			return;
		}
		AgentAction action = new AnimationAction(animationName, false, false);
		this.humanoid.ai.DisableAI();
		this.humanoid.ai.behaviorController.StopMainBehavior();
		this.humanoid.actionManager.ClearAll();
		this.humanoid.actionManager.ScheduleAction(action);
		if (this.humanoid.isGiantess)
		{
			this.giantess.InvokeColliderUpdate();
			this.giantess.GtsMovement.doNotMoveGts = true;
			this.giantess.DestroyFingerPosers();
		}
	}

	// Token: 0x0600173F RID: 5951 RVA: 0x00094A61 File Offset: 0x00092C61
	public void UpdateCollider()
	{
		if (this.giantess == null)
		{
			return;
		}
		this.giantess.ForceColliderUpdate();
	}

	// Token: 0x06001740 RID: 5952 RVA: 0x00094A80 File Offset: 0x00092C80
	public void ChangeAnimationSpeed(float speed)
	{
		if (this.giantess == null)
		{
			if (this.humanoid != null)
			{
				this.humanoid.animationManager.ChangeSpeed(speed);
			}
			return;
		}
		this.giantess.movement.anim.ChangeSpeed(speed);
	}

	// Token: 0x06001741 RID: 5953 RVA: 0x00094AD8 File Offset: 0x00092CD8
	public float GetAnimationSpeed()
	{
		if (!(this.giantess == null))
		{
			return this.giantess.movement.anim.speedMultiplier;
		}
		if (this.humanoid != null)
		{
			return this.humanoid.animationManager.speedMultiplier;
		}
		return 0f;
	}

	// Token: 0x06001742 RID: 5954 RVA: 0x00094B34 File Offset: 0x00092D34
	public void SetPose(string namePose)
	{
		if (this.humanoid == null)
		{
			return;
		}
		this.humanoid.ai.DisableAI();
		this.humanoid.ai.behaviorController.StopMainBehavior();
		this.humanoid.actionManager.ClearAll();
		this.humanoid.animationManager.PlayAnimation(namePose, true, false);
	}

	// Token: 0x06001743 RID: 5955 RVA: 0x00094B9B File Offset: 0x00092D9B
	public void EnablePoseIK(bool enable)
	{
		if (this.giantess == null)
		{
			return;
		}
		this.giantess.ik.SetPoseIK(enable);
	}

	// Token: 0x06001744 RID: 5956 RVA: 0x00094BC0 File Offset: 0x00092DC0
	public void DeleteObject()
	{
		if (this.selectedEntity && !this.selectedEntity.GetComponent<Weld>())
		{
			this.selectedEntity.DestroyObject(true);
			this.SetSelectedObject(null, true);
		}
	}

	// Token: 0x06001745 RID: 5957 RVA: 0x00094BFB File Offset: 0x00092DFB
	public void LockRotation(bool value)
	{
		this.lockRotation = value;
	}

	// Token: 0x06001746 RID: 5958 RVA: 0x00094C04 File Offset: 0x00092E04
	public void PlayAsGiantess(string name, bool useAlternateShaders, bool useAlternateTangents)
	{
		Player playerInstance = GameController.playerInstance;
		GameController.Instance.spawner.CallCmdSpawnPlayableGiantess(name, playerInstance.myTransform.position, playerInstance.Scale * 0.001f, useAlternateShaders, useAlternateTangents);
		this.SetSelectedObject(playerInstance.transform.parent.GetComponent<Giantess>(), true);
	}

	// Token: 0x040019AB RID: 6571
	public static InterfaceControl Instance;

	// Token: 0x040019AC RID: 6572
	public bool commandEnabled = true;

	// Token: 0x040019AD RID: 6573
	public static float macroStartingScale = 0.02f;

	// Token: 0x040019AE RID: 6574
	public static float microStartingScale = 1f;

	// Token: 0x040019B4 RID: 6580
	private float lastRotationX;

	// Token: 0x040019B5 RID: 6581
	private float lastRotationY;

	// Token: 0x040019B6 RID: 6582
	private float lastRotationZ;

	// Token: 0x040019BC RID: 6588
	private float giantessOffsetDivisor = 3f;

	// Token: 0x0200037D RID: 893
	// (Invoke) Token: 0x06001749 RID: 5961
	public delegate void Selected();
}
